<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://"+request.getServerName()+ ":"+request.getServerPort()+path+ "/"; %>

		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml">

		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
			<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
			<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
			<title>文章管理</title>
			<script type="text/javascript" src="<%= basePath%>nresources/njs/jquery-1.4.js"></script>
			<script type="text/javascript">
				function subPost(page){
					$("#page").val(page);
					document.getElementById('artform').submit();
				}
				function delAtr(){
					var idsize = $("#showtable tbody input:checked").size();
					var mes=confirm("您确定要删除这"+ idsize +"个文章吗？");
					if(mes==true){
						var ids = [];
						var objects = $("#showtable tbody input:checked");
						for(var i=0;i<idsize;i++){
							ids[i] = objects[i].id;
						}
						$.ajax({
							type:"get",
							url:"<%= basePath%>back/delAtr.do",
							data:{"ids":ids.join(",")},
							success:function(data){
								alert("删除成功");
								document.getElementById('artform').submit();
							}
						});
					}
				}
				function hiddenAtr(){
					var idsize = $("#showtable tbody input:checked").size();
					var mes=confirm("您确定要隐藏这"+ idsize +"个文章吗？");
					if(mes==true){
						var ids = [];
						var objects = $("#showtable tbody input:checked");
						for(var i=0;i<idsize;i++){
							ids[i] = objects[i].id;
						}
						$.ajax({
							type:"get",
							url:"<%= basePath%>back/hiddenAtr.do",
							data:{"ids":ids.join(",")},
							success:function(data){
								alert("隐藏成功");
								document.getElementById('artform').submit();
							}
						});
					}
				}
				function selectAll(){
				    if ($("#checkall").attr("checked")) {
				        $("#showtable tbody input:checkbox").attr("checked", "checked");  
				    } else {
				        $("#showtable tbody input:checked").attr("checked", false);  
				    }
				}
				function updateAtr(id){
					window.open('<%= basePath%>back/showAtrDetail.do?id='+id,id,'height=600,width=800');
				}
			</script>
		</head>

		<body>
			<form action="querylist.do" method="post" class="form-inline" role="form" name="bean" id="artform">
				<table>
					<tr>
						<td>
							文章标题	<input id="atrname" name="atrname" value="${bean.atrname}"/>
							文章类型 <input id="atrtype" name="atrtype" value="${bean.atrtype}"/>
							开始时间 <input id="starttime" name="starttime" type ="date" value="${bean.starttime}"/>
							结束时间	<input id="endtime" name="endtime" type="date" value="${bean.endtime}"/>
							<input id="page" name="page" type="hidden" value="${bean.page}"/>
							<input type="submit" value="搜索" class="btn btn-default" />
							<input type="button" value="删除" onclick="delAtr()" class="btn btn-default" />
							<input type="button" value="隐藏" onclick="hiddenAtr()" class="btn btn-default" />
						</td>
					</tr>
				</table>
				<nav>
					<ul class="pagination  pagination-sm">
						<li><a href="javascript:subPost(1)" title="首页">&laquo;</a></li>
						<c:forEach var="i" items="${index}" varStatus="s">
							<c:if test="${i==page}">
								<li class="active"><a href="javascript:subPost(${i})">${i}</a></li>
							</c:if>
							<c:if test="${i!=page }">
								<li ><a href="javascript:void" onclick="subPost(${i})">${i}</a></li>
							</c:if>
						</c:forEach>
						<li><a href="javascript:subPost(${endnum})" title="末页">&raquo;</a></li>
					</ul>
				</nav>
			</form>
			<table class="table table-hover" id="showtable">
				<thead>
					<tr>
						<th><input type="checkbox" id="checkall" onclick="selectAll()"/>全选</th>
						<th>文章标题</th>
						<th>文章类型</th>
						<th>发布时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${not empty arts}">   
  						<c:forEach var="artbean" items="${arts}" varStatus="s">
							<tr>
								<td><input type="checkbox" id="${artbean.id}" /></td>
								<td>${artbean.title}</td>
								<td>${artbean.type}</td>
								<td><fmt:formatDate value="${artbean.createTime}" pattern="yyyy-MM-dd"/></td>
								<td><a href="javascript:void" onclick="updateAtr(${artbean.id})">修改</a></td>
							</tr>
						</c:forEach>
					</c:if>
				</tbody>
			</table>
		</body>